package com.xk857.article.controller;



import com.xk857.article.service.ICommentService;
import com.xk857.entities.Comment;
import com.xk857.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 评论信息表 前端控制器
 *
 * @author CV大魔王
 * @since 2021-02-21
 */
@Api(value = "评论管理接口",tags = "评论管理接口")
@RestController
@RequestMapping("/pri/comment")
public class CommentController {

    @Autowired
    private ICommentService commentService;

    @ApiImplicitParam(name="id", value="评论ID", required=true)
    @ApiOperation("删除评论接口")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable("id") String id) {
        return commentService.deleteById(id);
    }

    @ApiOperation("新增评论信息接口")
    @PostMapping
    public Result save(@RequestBody Comment comment) {
        commentService.save(comment);
        return Result.ok("添加成功");
    }


    @ApiOperation("查询今日评论数量")
    @GetMapping("/search/count/day/num")
    public Integer searchCountDayNum() {
        return commentService.searchCountDayNum();
    }

    @ApiOperation("查询昨日评论数量")
    @GetMapping("/search/count/yesterday/num")
    public Integer searchNumberOfArticlesInYesterdaySDay() {
        return commentService.searchNumberOfArticlesInYesterdaySDay();
    }

    @ApiOperation("查询近七天评论数量")
    @GetMapping("/search/count/week/num")
    public Integer searchNumberOfArticlesInWeek() {
        return commentService.searchNumberOfArticlesInWeek();
    }

}
